<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<!-- js测试练习 -->
		<script>
			// for(var i = 1; i <= 9; i++){
			// 	console.log(i);
			// }
				
			// for(var i = 1; i <= 9; i++){
			// 	for(var j = 1;j <= i; j++){
			// 		var out = i + "*" + j + "=" + i * j;
			// 		console.log(out);
			// 	}
			// }
			
			var arr = [31,24,37,11];
			console.log(arr.push(55,61,77));
			console.log(arr.pop());
			console.log(arr.length)
			console.log(arr.unshift(71,83,91));
			console.log(arr.length);
			console.log(arr.shift());
			console.log(arr.length);
			
			arr.forEach((item, i) => {
				console.log(`元素${item}和它的位置${i}`);
			});
			
			arr.filter((item, i) => {
				return item > 50;
			}).forEach((item, i) =>{
				console.log(`${item}大于50,而且它的新位置是${i}`);
			})
			
			var firstItem = arr.find((item, i) =>{
				return item > 50;
			})			
			console.log(`第一个大于50的元素为${firstItem}`);
			
			var arr2 = [
				{ id: 1, name: "张三"},
				{ id: 2, name: "李四"},
				{ id: 3, name: "王五"},
				{ id: 4, name: "马六"},
				{ id: 5, name: "杜七"}
			];
			
			console.log(
				`indexOf得到的的索引是${
					arr2.indexOf((item, i) => {
						return item.id === 3 && item.name === "王五";
					})
				}`
			);
			console.log(`findIndex得到的索引是${arr2.findIndex(item => item.id === 4)}`);
			
		</script>
	</body>
</html>
